import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import axios from 'axios'
const API_URL = 'https://geek.itheima.net/v1_0/channels'
export const useCounterStore = defineStore('counter',()=>{
    const count = ref(0)
    function increment() {
        count.value++
    }
    //getter
    const doublecount = computed(()=>{
        return count.value * 2
    })
    //actions异步调用
    const list = ref([])
    const getList = async()=>{
        const res = await axios.get(API_URL)
        list.value = res.data.data.channels
    }

    return { count,doublecount,increment,list,getList }
})
